﻿<html DIR="LTR" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
  <head>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8" />
    <META NAME="save" CONTENT="history" />
    <title>Readme_ForEachDirectory Sample</title>
    
    
    
    <style TYPE="text/css">
body
{
background: #FFFFFF;
color: #000000;
font-family:    Verdana;
font-size: medium;
font-style: normal;
font-weight: normal;
margin-top: 0;
margin-bottom:  0;
margin-left:    0;
margin-right:   0;
width:  100%;
}

div.#mainSection
{
font-size: 70%;
width: 100%;
padding-left:    10;
margin-right: 10;
}

div.#mainBody
{
font-size: 90%;
margin-top: 10;
padding-bottom: 20;
}

div.#header
{
background-color: #D2D2D2;
padding-top:    0;
padding-bottom: 0;
padding-left:   10;
padding-right:  0;
width:          100%;
}

div.#header table
{
border-bottom-color: #C8CDDE;
border-bottom-style: solid;
border-bottom-width: 1;
width:  100%;
}

span.#runningHeaderText
{
color: #003399;
font-size: 90%;
}

span.#nsrTitle
{
/*    color: #003399;*/
font-size: 120%;
font-weight: 600;
}

div.#header table td
{
color: #000000;
font-size: 70%;
margin-top: 0;
margin-bottom:  0;
padding-right: 20;
}

div.#header table tr.#headerTableRow3 td
{
padding-bottom: 2;
padding-top: 5;
}

div.#header table.#bottomTable
{
border-top-color: #FFFFFF;
border-top-style: solid;
border-top-width: 1;
text-align: left;
}

div.#footer
{
font-size: 90%;
margin-top: 0;
margin-bottom:  0;
margin-left:    -5;
margin-right:   0;
padding-top:    2;
padding-bottom: 2;
padding-left:   0;
padding-right:  0;
width:  100%;
}

hr.#footerHR
{
border-bottom-color: #EEEEFF;
border-bottom-style: solid;
border-bottom-width: 1;
border-top-color: C8CDDE;
border-top-style: solid;
border-top-width: 1;
height: 3;
color: #D2D2D2;
}

div.section
{
padding-top:    2;
padding-bottom: 2;
padding-right:  15;
width:  100%;
}

.heading
{
color:          #000000;
font-weight:    bold;
margin-top:     18;
margin-bottom:  8;
}

h1.heading
{
color: #000000;
font-size:  150%;
}

.subHeading
{
color:          #000000;
font-weight:    bold;
font-size:      150%;
margin-bottom:  4;
}

h2.subHeading
{
color:          #000000;
font-weight:    bold;
font-size:      130%;
}
h3.subHeading
{
color:  #000000;
font-size: 125%;
font-weight: bold;
}

h4.subHeading
{
color: #000000;
font-size: 110%;
font-weight: bold;
}

h4.procedureHeading
{
color: #000080;
font-size: 110%;
font-weight: bold;
}

h5.subHeading
{
color: #000000;
font-size: 100%;
font-weight: bold;
}

img
{
padding-bottom: 10;
}

img.toggle
{
border: 0;
margin-right: 5;
padding-bottom: 10;
}

img.copyCodeImage
{
border: 0;
margin: 1;
margin-right: 3;
padding-bottom: 10;
}

img.downloadCodeImage
{
border: 0;
margin-right: 3;
padding-bottom: 10;
}

img.viewCodeImage
{
border: 0;
margin-right: 3;
padding-bottom: 10;
}

img.note
{
border: 0;
margin-right: 3;
padding-bottom: 10;
}

img.#membersOptionsFilterImage
{
border: 0;
margin-left: 10;
vertical-align: middle;
padding-bottom: 10;
}

img.#toggleAllImage
{
margin-left: 4;
vertical-align: middle;
padding-bottom: 10;
}

div.#mainSection table
{
border: 0;
font-size: 100%;
width:  100%;
margin-top: 5px;
margin-bottom: 15px;
}

div.#mainSection table tr
{
vertical-align: top;
}

div.#mainSection table th
{
text-align: left;
background: #D8D8D8;
border-bottom-color: #D8D8D8;
border-bottom-style: solid;
border-bottom-width: 1;
color: #000000;
padding-left: 5;
padding-right: 5;
}

div.#mainSection table td
{
background: #F2F2F2;
border-top-color: #D8D8D8;
border-top-style: solid;
border-top-width: 1;
padding-left: 5;
padding-right: 5;
}

div.#mainSection table td.imageCell
{
white-space: nowrap;
}

div.code
{
width: 98%;
}

div.code table
{
border: 0;
font-size: 95%;
margin-bottom: 5;
width: 100%
}

div.code table th
{
text-align: left;
background: #D8D8D8;
border-bottom-color: #D8D8D8;
border-bottom-style: solid;
border-bottom-width: 1;
color: #000000;
font-weight: bold;
padding-left: 5;
padding-right: 5;
}

div.code table td
{
background: #CCCCCC;
border-top-color: #D8D8D8;
border-top-style: solid;
border-top-width: 1;
padding-left: 5;
padding-right: 5;
padding-top: 5;
}

div.alert
{
margin-left: 10;
width: 98%;
}

div.alert table
{
border: 1;
font-size: 100%;
width:  100%;
border: solid 1 #DEDFEF;
}

div.alert table th
{
text-align: left;
background: #D8D8D8;
border-bottom-width: 0;
color: #000000;
padding-left: 5;
padding-right: 5;
border: solid 1 #DEDFEF;
}

div.alert table td
{
background: #FFFFFF;
border-top-color: #D8D8D8;
border-top-style: solid;
border-top-width: 1;
padding-left: 5;
padding-right: 5;
border: solid 1 #DEDFEF;
}

span.copyCode
{
color: #0000ff;
font-size: 90%;
font-weight: normal;
cursor: hand;
float: right;
display: inline;
text-align: right;
}

.downloadCode
{
color: #0000ff;
font-size: 90%;
font-weight: normal;
cursor: hand;
}

.viewCode
{
color: #0000ff;
font-size: 90%;
font-weight: normal;
cursor: hand;
}

div.code pre
{
font-family:    Monospace, Courier New, Courier;
font-size: 105%;
color:  #000000;
}

code
{
font-family:    Monospace, Courier New, Courier;
font-size: 105%;
color:  #000000;
}

dl
{
margin-top: 0;
padding-left:   1;
}

dd
{
margin-bottom:  0;
margin-left:    0;
padding-left:   20;
}

dd p
{
margin-top: 5;
}

ul
{
margin-left: 17;
list-style-type: disc;
}

ul ul
{
margin-bottom: 4;
margin-left: 17;
margin-top: 3;
list-style-type: disc;
}

ol
{
margin-left: 24;
list-style-type: decimal;
}

ol ol
{
margin-left: 24;
margin-top: 3;
list-style-type: lower-alpha;
}

li
{
margin-top: 0;
margin-bottom: 0;
padding-bottom: 0;
padding-top: 0;
margin-left: 5;
}

p
{
margin-bottom: 15;
}

.tip
{
color:  #0000FF;
font-style: italic;
cursor:hand;
text-decoration:underline;
}

.math
{
font-family: Times New Roman;
font-size: 125%
}
.sourceCodeList
{
font-family: Verdana;
font-size: 90%;
}

pre.viewCode
{
width: 100%;
overflow: auto;
}

li:hover table, li.over table
{
background-color: #C0C0C0;
}

li:hover ul, li.over ul
{
background-color: #d2d2d2;
border: 1px solid #000;
display: block;
}
            </style>
  </head>
  <body>
    <!--Topic built:08/05/2008 01:28:33-->

    
    
    
    
    
    
    
    
    
    <div id="header">
      <table width="100%" id="topTable"><tr>
          <td align="left">
            <span id="nsrTitle">Readme_ForEachDirectory Sample</span>
          </td>
          <td align="right">
            <span id="headfb" class="feedbackhead">
            </span>
          </td>
        </tr></table>
      
      
      
    </div>
    <div id="mainSection">
      <div id="mainBody"><p> 08/05/2008 01:28:33</p>
        
        <font color="DarkGray"> </font><p /> 
        <span id="changeHistory">
        </span>
    <p>
      This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005.
    </p>
    <p>This code sample demonstrates how to create a custom enumerator and a custom user interface to set properties for the enumerator using the .NET Framework and managed code. </p>
    <p>This sample is not supported on Itanium-based operating systems.</p>
    <div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Important: </th></tr><tr><td>
      Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples.<p />
    </td></tr></table><p /></div>
  <h1 class="heading">Running the Sample</h1><div id="sectionSection0" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">If you already know how to locate, build, and install code samples, you can go directly to the section, <a href="#testing">Testing the Sample</a>, and read about how to configure and run the code sample.</p>
    </content></div><h1 class="heading">Prerequisites</h1><div id="sectionSection1" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">The ForEachDirectory sample requires that the following components are installed.</p>
      <ul xmlns=""><li>
          
            .NET Framework SDK 2.0 or Microsoft Visual Studio. You can obtain .NET Framework SDK free of charge. See the Books Online topic, <b>Installing the .NET Framework Documentation</b>.<br />
        </li><li>
          
            Microsoft SQL Server Integration Services <br />
        </li></ul>
    </content></div><h1 class="heading">Location</h1><div id="sectionSection2" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">If the code sample was installed to the default location, the sample is located in the following directory:</p>
      <p xmlns="">
        C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Programming Samples\Control Flow\ForEachDirectory Sample</p>
      <p xmlns="">The C# solution for the code sample is located in the CS directory, and the Visual Basic solution is located in the VB directory. </p>
      <p xmlns="">For information about the two-step process required to install the samples, see <a href="html/e8117979-fe03-441e-be85-894fa616227a.htm">Considerations for Installing SQL Server Samples and Sample Databases</a>.</p>
    </content></div><h1 class="heading">Building the Sample</h1><div id="sectionSection3" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">If you have not already generated a strong name key file, use the following procedure to generate this key file. </p>
      <h4 class="procedureHeading" xmlns="">To generate a strong name key file</h4><div id="procedureSectionEDBHBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">To open a Microsoft Visual Studio command prompt, click <b>Start</b>, point to <b>All Programs</b>, point to <b>Microsoft Visual Studio 2008</b>, point to <b>Visual Studio Tools</b>, and then click <b>Visual Studio 2008 Command Prompt</b>.</p>
              <p xmlns="">- or -</p>
              <p xmlns="">To open a Microsoft .NET Framework command prompt, click <b>Start</b>, point to <b>All Programs</b>, point to <b>Microsoft .NET Framework SDK 2.0</b>, and then click <b>SDK Command Prompt</b>.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">At the command prompt, use the change directory (CD) command to change the current folder of the command prompt window to the Samples folder. The key file that you create in this folder will be used by all SQL Server code samples.</p>
              <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
                To determine the folder where samples are located, click <b>Start</b>, point to <b>All Programs</b>, point to <b>Microsoft SQL Server 2008</b>, point to <b>Documentation and Tutorials</b>, and then click <b>Samples Directory</b>. If the default installation location was used, the samples are located in <i>&lt;drive&gt;</i>:\Program Files\Microsoft SQL Server\100\Samples.<p />
              </td></tr></table><p /></div>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">At the command prompt, run the following command to generate the key file:</p>
              <p xmlns="">
                <b>sn -k SampleKey.snk</b>
              </p>
              <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Important: </th></tr><tr><td>
                For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.<p />
              </td></tr></table><p /></div>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">You will need the public key token from the key file in a subsequent step. To obtain the public key token, first extract the public key from the key file by running the following command at the command prompt:</p>
              <p xmlns="">
                <b>sn -p SampleKey.snk SampleKeyPublic.snk</b>
              </p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Display the public key token by running the following command at the command prompt: </p>
              <p xmlns="">
                <b>sn -t SampleKeyPublic.snk</b>
              </p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Copy the public key token to the clipboard or save for later use.</p>
            </content>
          </li></ol></div>
      <h4 class="procedureHeading" xmlns="">To build the sample</h4><div id="procedureSectionEBBHBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Open <b>Microsoft Visual Studio 2008</b>.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">From the <b>File</b> | <b>Open</b> menu, click <b>Project</b> and open the ForEachDirectory.sln in the desired Samples directory, which is CS for the C# language, or VB for the Visual Basic language.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">In the Solution Explorer, select the ForEachDirectory.cs or ForEachDirectory.vb code.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">In the code, locate the <b>DtsForEachEnumerator</b> attribute. In that line of code, replace the existing value of the public key token in the<b> UITypeName</b> attribute property. The alphanumeric value after "<b>PublicKeyToken</b> =" should be replaced with the one displayed in the <b>sn -t</b> command from a previous step.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Click <b>Build</b> / <b>Build ForEachDirectory</b> on the menu to build the DLL for the project.</p>
            </content>
          </li></ol></div>
    </content></div><h1 class="heading">Installing the DLL into the ForEachEnumerator folder and the Global Assembly Cache</h1><div id="sectionSection4" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">This sample is provided in both Visual Basic and C#. To distinguish between the assemblies for each version of the sample, the name of the output assembly has CS or VB appended. After successfully building the component, the component must be copied to the ForEachEnumerators folder, and then added to the Global Assembly Cache in order to use it in Business Intelligence Development Studio.</p>
      <h4 class="procedureHeading" xmlns="">To install the component into the ForEachEnumerators folder</h4><div id="procedureSectionELBFBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Open Windows Explorer or your preferred application for working in the file system.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Copy the assembly (ForeachDirectoryCS.dll or ForeachDirectoryVB.dll) to the folder located at <b>%system%\Program Files\Microsoft SQL Server\100\DTS\ForEachEnumerators</b>.</p>
            </content>
          </li></ol></div>
      <h4 class="procedureHeading" xmlns="">To install the component into the Global Assembly Cache by dragging and dropping the assembly</h4><div id="procedureSectionEJBFBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Open Windows Explorer or your preferred application for working in the file system.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Drag the assembly from the ForEachEnumerators folder to the folder where the global assembly cache (GAC) is located, at %system%\assembly.</p>
            </content>
          </li></ol></div>
      <h4 class="procedureHeading" xmlns="">To install the component into the Global Assembly Cache by using gacutil.exe</h4><div id="procedureSectionEHBFBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Open a Command Prompt window.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Type the following command to install the C# version of the component and the user interface into the global assembly cache:<b> </b></p>
              <p xmlns="">
                <code>gacutil.exe -iF "c:\Program Files\Microsoft Sql Server\100\DTS\ ForEachEnumerators\ForEachDirectoryCS.dll"</code>
              </p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Type the following command to install the Visual Basic version of the component and the user interface into the global assembly cache:<b> </b></p>
              <p xmlns="">
                <code>gacutil.exe -iF "c:\Program Files\Microsoft Sql Server\100\DTS\ForeachEnumerators\ForeachDirectoryVB.dll"</code>
              </p>
            </content>
          </li></ol></div>
      <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
        For simplicity, the user interface for this sample has been put in the same project as the task code; therefore, copying the DLL into the assembly directory is all that is required. If you decide to code the user interface in a different project, then you must add the DLL that contains the user interface to the global assembly cache, in addition to the DLL that contains the code. Only the code must be compiled into a specific directory, however.<p />
      </td></tr></table><p /></div>
      <p xmlns="">After you complete these steps the enumerator is available in the <b>For Each Loop Editor</b> of the For Each Loop container.</p>
      <h4 class="procedureHeading" xmlns="">To use the sample in Business Intelligence Development Studio </h4><div id="procedureSectionEBBFBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Open Business Intelligence Development Studio.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">From the menu, click <b>File</b> | <b>New</b> | <b>Project</b>.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">From the <b>New Project</b> dialog box, in the <b>Project Types</b>, click <b>Business Intelligence Projects</b> and in the right pane, click <b>Integration Services Project</b>.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">In the <b>Name</b> box, type <i>ForEachDirectory</i> as the name for the new project. </p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">In the <b>Location</b> box, select the location where you want to save the file. Click <b>OK</b>.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">From the <b>Solution Explorer</b> dialog box, double-click Package.dtsx.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">In the <b>Location</b> box, select the location you want to save the file to. Click <b>OK</b>.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">From the <b>Solution Explorer</b> dialog box, double-click Package.dtsx.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Add the ForEachLoop container to the Control Flow surface of a package.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Open the Foreach Loop Editor by double-clicking the ForEachLoop container added in step one.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Click the <b>Collection</b> node, and select the ForEachDirectory enumerator from the Enumerator dropdown.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Specify the values of the properties of the ForEachDirectory enumerator, and then click <b>OK</b>.</p>
            </content>
          </li></ol></div>
    </content></div><a name="testing" /><h1 class="heading">Testing the Sample</h1><div id="sectionSection5" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">After you have added the sample component to a Data Flow task in a package, you can configure it in SSIS Designer. The ForEachDirectory enumerator has five properties that control its execution behavior.</p>
      <table width="100%" cellspacing="0" cellpadding="0" border="1" style="background-color: #CCCCCC;" xmlns=""><tr>
            <th>
              Property
            </th>
            <th>
              Description
            </th>
          </tr><tr>
          <td>
            <p>RootDirectorySource</p>
          </td>
          <td>
            <p>Specifies the source for the RootDirectory property which can be set by a ConnectionManager, Variable, or DirectInput.</p>
          </td>
        </tr><tr>
          <td>
            <p>RootDirectory</p>
          </td>
          <td>
            <p>Specifies the directory where the enumerator begins its enumerating.</p>
          </td>
        </tr><tr>
          <td>
            <p>IncludeRootDirectory</p>
          </td>
          <td>
            <p>Specifies whether the root directory is included in the directories that are enumerated.</p>
          </td>
        </tr><tr>
          <td>
            <p>EnumerateSubFolders</p>
          </td>
          <td>
            <p>Specifies whether the subfolders of the folders that is contained in the root directory are enumerated.</p>
          </td>
        </tr><tr>
          <td>
            <p>SiblingFoldersBeforeSubFolders</p>
          </td>
          <td>
            <p>When EnumerateSubFolders is <b>true</b>, specifies whether the enumerator enumerates the sibling folders first, or whether the complete directory structure is enumerated first.</p>
          </td>
        </tr></table>
    </content></div><!--[if gte IE 5]>
			<tool:tip element="seeAlsoToolTip" avoidmouse="false"/><tool:tip element="languageFilterToolTip" avoidmouse="false"/><tool:tip element="roleInfoSpan" avoidmouse="false"/>
		<![endif]--></div>
      <div id="footer">
			
			© 2008 Microsoft Corporation. All rights reserved.
		</div>
    </div>
  </body>
</html>